from Cryptography.Untility import LetterToNumber, NumberToLetter


def Crypt(text, shift):
    result = ""
    
    for c in text:
        if not LetterToNumber.has_key(c):
            result += c
        else:
            c_number = LetterToNumber[c]
            crypted_number = (c_number + shift) % len(LetterToNumber)
            crypted_c = NumberToLetter[crypted_number]
            result += crypted_c

    return result



def Decrypt(cipherText, originalCryptionShift):
    return Crypt(cipherText, originalCryptionShift*(-1))



def TryDecrypt(cipherText):
    result = {}

    for shift in range(len(LetterToNumber)):
        result[shift] = Decrypt(cipherText, shift)

    return result